package com.qf.api.recharge.fallback;

import com.qf.api.recharge.feign.RechargeFeignService;
import com.qf.common.core.common.R;
import com.qf.common.core.dto.BalanceChangeDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * @author TianWenHe
 * @date 2025/6/12
 * @desc
 */
@Slf4j
@Component
public class RechargeFallbackFactory implements FallbackFactory<RechargeFeignService> {
    @Override
    public RechargeFeignService create(Throwable cause) {
        return new RechargeFeignService() {
            @Override
            public R changeBalance(BalanceChangeDTO balanceChangeDTO) {
                log.error("changeBalance远程调用失败：{}", cause.getMessage());
                return R.fail("用户余额更新失败");
            }

            @Override
            public List<String> getAvatarsByUserIds(List<Integer> ids) {
                log.error("product:avatars:远程调用失败:{}", cause.getMessage());
                return Collections.emptyList();
            }
        };
    }
}
